package com.dys.spring.controller;

import com.dys.spring.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author: 疾风
 * @ClassName: UserController
 * @Description: User服务控制器
 * @CreateDate: 2024/10/18
 * @Version: v1.0.0
 */
@Component
public class UserController {
    /**
     * 通过构造器注入
     */
    private UserService userService;

    /**
     * 使用@Autowired解决依赖注入的问题
     */
    @Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }

    public void listUsers(){
        userService.findAllUser().forEach(System.out::println);
    }
}
